		<script type="text/javascript" language="Javascript">
		<!--
			function changeStyle(newObj) {
				//alert('1');
				var obj;
				if(obj==null) {
					//alert('2');
					obj=newObj;
					obj.className='selected';
				}else {
					if(obj!=newObj) {
						//alert('3');
						obj.className='';
						obj=newObj;
						obj.className='selected';
					}
				}
			}
			var sReady="<%=@sReady%>";
			var sSelect="<%=@sSelect%>";
			var t1,t2,i;
			var arrReady=new Array();
			var arrSelect=new Array(); 
			
			t1=sReady.split(";");
			for (i=0;i<t1.length;i++){
				if (t1[i]=="")
					t2=new Array();
				else
					t2=t1[i].split(",");
				arrReady[i]=t2;
			}
			t1=sSelect.split(";");
			for (i=0;i<t1.length;i++){
				if (t1[i]=="")
					t2=new Array();
				else
					t2=t1[i].split(",");
				arrSelect[i]=t2;
			}

			function loadChannel(index){
				document.getElementById("selList1").options.length=0;
				document.getElementById("selList2").options.length=0;
				if (arrReady[index]!=null && arrReady[index].length!=0){
					for (var i=0;i<arrReady[index].length;i++)
						document.getElementById("selList1").options[i]=new Option(arrReady[index][i],arrReady[index][i]);
				}
				if (arrSelect[index]!=null && arrSelect[index].length!=0){
					for (var i=0;i<arrSelect[index].length;i++)
						document.getElementById("selList2").options[i]=new Option(arrSelect[index][i],arrSelect[index][i]);
				}
			}
			function moveChannel(fromBox,toBox){
				for (var i=0;i<fromBox.length;i++){
					if (fromBox.options[i].selected){
						toBox.options[toBox.length]=new Option(fromBox.options[i].text,fromBox.options[i].text);
						fromBox.options[i]=null;
						i--;
					}
				}
			}
			function submitForm(){
				var sAdd="",sDel="";
				var m=document.getElementById("selList2").length;
				var n=arrSelect[document.getElementById("prov").selectedIndex].length;
				
				for (var i=0;i<m;i++){
					for (j=0;j<n;j++){
						if (document.getElementById("selList2").options[i].text==arrSelect[document.getElementById("prov").selectedIndex][j]) break;
					}
					if (j==n) sAdd+=document.getElementById("selList2").options[i].text+",";
				}
				for (var j=0;j<n;j++){
					for (i=0;i<m;i++){
						if (document.getElementById("selList2").options[i].text==arrSelect[document.getElementById("prov").selectedIndex][j]) break;
					}
					if (i==m) sDel+=arrSelect[document.getElementById("prov").selectedIndex][j]+",";
				}
				
				document.getElementById("hidRole").value=document.getElementById("account_role_id").options[document.getElementById("account_role_id").selectedIndex].value;
				document.getElementById("hidProv").value=document.getElementById("prov").options[document.getElementById("prov").selectedIndex].value;
				document.getElementById("hidAdd").value=sAdd;
				document.getElementById("hidDel").value=sDel;
				//alert("sAdd = ["+sAdd+"]\nsDel = ["+sDel+"]");
				document.assignRight.submit();
			}
		-->
		</script>

					<h1>权限分配 - <span id="secondHeading">分配操作权限</span></h1>
                                      <% if @flash[:notice] -%>
                                      <div id="notice"><%= @flash[:notice] %></div>
                                      <% end -%>
                                        <form id="input-form" name="assignRight" action="" method="post">
					<table id="INPUT_TABLE" border="0">
						<tbody>
                                                                <input id="hidRole" name="hidRole" type="hidden" value="" />
                                                                <input id="hidProv" name="hidProv" type="hidden" value="" />
                                                                <input id="hidAdd" name="hidAdd" type="hidden" value="" />
                                                                <input id="hidDel" name="hidDel" type="hidden" value="" />
							<tr>
								<td class="b2">角色名称：</td>
								<td>
									<select id="account_role_id" name="account[role_id]" onchange="location='assign_right?roleId='+this.options[this.selectedIndex].value;">
										<%@roles.each do |role|%>
										<option value="<%=role.id%>"<%=' selected' if role.id.to_i==@roleId.to_i%>><%=role.name%></option>
										<%end%>
									</select>
								</td>
							</tr>
							<tr>
								<td class="b2">模块名称：</td>
								<td>
									<select id="prov" name="prov" onchange="loadChannel(this.selectedIndex)">
										<option value="权限管理">权限管理</option>
										<option value="产品管理">产品管理</option>
										<option value="仓库管理">仓库管理</option>
										<option value="客户管理">客户管理</option>
										<option value="销售管理">销售管理</option>
                                                                                <!--<option value="打印">打印</option>-->
                                                                               	<option value="报表中心">报表中心</option>
										<option value="系统管理">系统管理</option>
									
									</select>
								</td>
							</tr>
							<tr>
								<td class="b2">选择频道：</td>
								<td>
									<table>
										<tbody>
										<tr>
											<td>
												<select multiple="multiple" id="selList1" style="width: 150px; height: 200px;"></select>
											</td>
											<td>
                                                                                                <div><input onclick="moveChannel(document.getElementById('selList1'),document.getElementById('selList2'))" value="&gt;&gt;" class="sub" type="button"/></div><br/>
												<div><input onclick="moveChannel(document.getElementById('selList2'),document.getElementById('selList1'))" value="&lt;&lt;" class="sub" type="button"/></div>
											</td>
											<td>
												<select multiple="multiple" id="selList2" style="width: 150px; height: 200px;"></select>
											</td>
										</tr>
										</tbody>
										<script type="text/javascript">
										      loadChannel(0);
										</script>
									</table>
								</td>
							</tr>
							<tr>
								<td colspan="2" align="right">
									<input value="确定" onclick="submitForm()" class="sub" type="button"/>
								</td>
							</tr>
						</tbody>
					</table>
                                </form>
